package team.first.movieapiv3.controller;

import io.swagger.annotations.ApiOperation;
import org.neo4j.ogm.session.Session;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import team.first.movieapiv3.domain.ResponseComment;
import team.first.movieapiv3.util.SessionFactoryUtil;
import team.first.movieapiv3.vo.ApiResponse;


/**
 * @Author: HAPPY
 * @Project_name: project
 * @Package_name: team.first.movieapiv3.controller
 * @Date: 2021/12/9 16:18
 * @Description:
 */
@RestController
public class CommentController {
    @GetMapping("/api/v3/movie/{id}/comments")
    @ApiOperation("1.6 GET： 获取指定编号的电影评论")
    public ApiResponse<ResponseComment> getMovieComment(@PathVariable("id") Integer movieId) {
        ApiResponse<ResponseComment> apiResponse = new ApiResponse<>();
        ResponseComment responseComment = new ResponseComment();
        Session session = SessionFactoryUtil.getSession("team.first.movieapiv3.domain");

        // comment关系的值查不到
        ResponseComment responseComment1 = session.load(ResponseComment.class, movieId,2);
        System.out.println(responseComment1);
        apiResponse.setCode(200).setSuccess(true).setMessage("请求成功").setData(responseComment1);
        return apiResponse;
    }
}
